package com.ruoyi.common.utils;

import com.alibaba.fastjson.JSON;

import java.math.BigDecimal;

/**
 * 佣金计算规则工具类
 */
public class ProfitCalRuleUtils {

    public static BigDecimal calProfit(String rule, BigDecimal crudeAmount) {
        BigDecimal ratio = BigDecimal.ZERO;
        if(StringUtils.isNotEmpty(rule)){
            ratio = JSON.parseObject(rule).getBigDecimal("ratio");
        }
        return ratio.multiply(crudeAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
    }
}
